package topic1;

import java.util.Arrays;

public class Topic1a {
    public static void main(String[] args) {
        int[] a = {1, 2, 3, 4, 5, 6, 7, 8, 9};
        int[] re = twoSum(a, 9);
        for (int i = 0;i< re.length;i++){
            System.out.println(re[i]);
        }
         // System.out.println(re);  地址值
        // toString
        System.out.println(Arrays.toString(re));


    }

    public static int[] twoSum(int[] nums, int target) {
        for (int i = 0; i < nums.length; i++) {
            for (int j = 0; j < nums.length; j++) {
                if (nums[i] + nums[j] == target) {
                    return new int[]{i, j};
                }
            }
        }
        return new int[0];
    }
}
